package com.hserver.service;

import com.hserver.entity.UserInfo;
import com.simonalong.neo.Neo;
import com.simonalong.neo.NeoMap;
import com.simonalong.neo.db.NeoPage;
import cn.hserver.core.ioc.annotation.Autowired;
import cn.hserver.core.ioc.annotation.Bean;

import java.util.List;


@Bean
public class UserService {

    private String TABLE="user_info";

    @Autowired
    private Neo neo;

    public Integer getUserCount() {
        return neo.count(TABLE);
    }

    public void setUser() {
        UserInfo userInfo = new UserInfo();
        userInfo.setAge(20);
        //下划线和驼峰都可以
        userInfo.setUser_name("小王");
        neo.insert(TABLE, userInfo);
    }

    public List<NeoMap> getUser() {
        List<NeoMap> page = neo.page(TABLE, NeoPage.of(1, 10));
        return page;
    }

}
